package edu.cibertec.util;

import javax.mail.Message;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import java.util.Properties;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;


public class JavaMail {
	
	
	//Bienvenido al nuestra empresa CiberStudio
	public static void EnviarCorreo(String titulo, String mensaje, String correoenviar) throws AddressException, MessagingException{
		
	
			Properties props = new Properties();
			props.put("mail.smtp.auth", "true");
			props.put("mail.smtp.starttls.enable", "true");
			props.put("mail.smtp.host", "smtp.gmail.com");
			props.put("mail.smtp.port", "587");
			Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
				protected PasswordAuthentication getPasswordAuthentication() {
					return new PasswordAuthentication("calidad.proy@gmail.com", "");
				}
			});
			Message message = new MimeMessage(session);
			message.setFrom(new InternetAddress("calidad.proy@gmail.com"));
			message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(correoenviar));
			message.setSubject(titulo);
			message.setText(mensaje);
			Transport.send(message);
		
		System.out.println("Done");
	}
	
	



}
